/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pl.cezary.butler.walili.client;

import java.util.logging.Level;
import java.util.logging.Logger;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import pl.cezary.butler.walili.client.gui.DownloaderGUI;

/**
 *
 * @author Czarek
 */
public class DownloaderApp {
    private static final Logger log = java.util.logging.Logger.getLogger(DownloaderApp.class.getName());
    
    private static ApplicationContext context;
    
    public static ApplicationContext initSpringContext() {
        if(context==null){
            try {
                context = new ClassPathXmlApplicationContext(ClientApp.class.getPackage().getName().replace('.', '/') + "/downloader.xml");
            } catch (BeansException ex) {
                log.log(Level.SEVERE, "Pobranie kontekstu spring nie powiodło się", ex);
            }
        }
        return context;
    }

    public static void main (String[] args) {     
        initSpringContext();
        final DownloaderGUI gui=new DownloaderGUI();
            
        LoginControler klog = new LoginControler();
        klog.connectDataSource(gui);        
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                gui.setVisible(true);

            }
        });
        
        return ;
    }

    public static ApplicationContext getContext() {
        return context;
    }
}
